package com.jiamao.goplay.ui.user.vm;

import android.os.Bundle;
import android.view.View;

import com.jiamao.goplay.ui.photo.PhotoViewFragment;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class EditUserPhotoItemVM extends MultiItemViewModel {

    public ObservableField<String> imgUrl = new ObservableField<>("");
    //public ObservableField<Integer> isDefaul = new ObservableField<>(0);
    public ObservableField<String> statusStr = new ObservableField<>();

    public ObservableField<Integer> isDefaul = new ObservableField<>(View.GONE);
    public ObservableField<Integer> isRenZhen = new ObservableField<>(View.GONE);
    public ObservableField<Integer> isstatusStr = new ObservableField<>(View.VISIBLE);

    public com.jiamao.goplay.bean.AvatarList avatarList;
    public EditUserPhotoItemVM(@NonNull BaseViewModel viewModel, com.jiamao.goplay.bean.AvatarList avatarList) {
        super(viewModel);
        this.avatarList = avatarList;
        if (avatarList!=null){
            imgUrl.set(avatarList.getUrl());
        }

        if (avatarList.getType() == 0 ){
            isDefaul.set(View.VISIBLE);
           // isRenZhen.set(View.VISIBLE);
            if (((EditUserInfoNM)viewModel).isTouXiangRenzh == 1){
                isRenZhen.set(View.VISIBLE);
            }
        }

        else if (avatarList.getIsDefault() == -1){
            isstatusStr.set(View.GONE);
        }

        switch (avatarList.getAuth()){
            case 0:
                statusStr.set("待审核");
                isstatusStr.set(View.VISIBLE);
                break;
            case 1:
                statusStr.set("审核成功");
                isstatusStr.set(View.GONE);
                break;
            case 2:
                statusStr.set("审核失败");
                isstatusStr.set(View.VISIBLE);
                break;

        }
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            
//            if (imgList == null){
//                imgList = new ArrayList<>();
//                imgList.add(imgUrl.get());
//            }
//            Bundle bd = new Bundle();
//            bd.putStringArrayList("list",imgList);
//            viewModel.startContainerActivity(PhotoViewFragment.class.getCanonicalName(),bd);

            ((EditUserInfoNM)viewModel).showUpateImage(EditUserPhotoItemVM.this);
           // viewModel.startContainerActivity(SearchFragment.class.getCanonicalName());
        }
    });
}
